33b0eaaa5ce9538aaf808a0d9aa4c389973b2cf5,src/main/java/org/dstadler/jgit/unfinished/PushToRemoteRepository.java,PushToRemoteRepository,main,#String[]#,40

Before Change


    public static void main(String[] args) throws IOException, InvalidRemoteException, TransportException, GitAPIException {
        // prepare a new folder for the cloned repository
        File localPath = File.createTempFile("TestGitRepository", "");
        localPath.delete();

        // then clone
        System.out.println("Cloning from " + REMOTE_URL + " to " + localPath);

After Change


    public static void main(String[] args) throws IOException, GitAPIException {
        // prepare a new folder for the cloned repository
        File localPath = File.createTempFile("TestGitRepository", "");
        if(!localPath.delete()) {
            throw new IOException("Could not delete temporary file " + localPath);
        }

        // then clone
        System.out.println("Cloning from " + REMOTE_URL + " to " + localPath);
        try (Git result = Git.cloneRepository()
                .setURI(REMOTE_URL)
                .setDirectory(localPath)
                .call()) {
            // prepare a second folder for the 2nd clone
            File localPath2 = File.createTempFile("TestGitRepository", "");
            if(!localPath2.delete()) {
                throw new IOException("Could not delete temporary file " + localPath2);
            }

            // then clone again
            System.out.println("Cloning from file://" + localPath + " to " + localPath2);
            try (Git result2 = Git.cloneRepository()
                    .setURI("file://" + localPath)
                    .setDirectory(localPath2)
                    .call()) {
                System.out.println("Result: " + result2);

                // now open the created repository
                FileRepositoryBuilder builder = new FileRepositoryBuilder();